<div class="popup_body clearfix">
    <div class="tab_item" style="display:block;">
        <div class="ui_table">
            <form>
                <table cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                        <td width="100px" align="right">设备编号：</td>
                        <td><input type="text" class="text easyui-validatebox" required="true" name="id" value=""
                                   maxlength="6" validType="unique[]"/>
                        </td>
                        <td width="100px" align="right">设备名称：</td>
                        <td><input type="text" class="text easyui-validatebox" required="true" name="cabinetName"
                                   maxlength="40"
                                   value=""/></td>
                    </tr>
                    <tr>
                        <td align="right">IP地址：</td>
                        <td><input type="text" class="text easyui-validatebox" name="ip" value="" maxlength="20"/>
                        </td>
                        <td align="right">是否启用：</td>
                        <td><input type="checkbox" class="checkbox" name="activeFlag" value="1" checked/></td>
                    </tr>
                    <tr>
                        <td align="right">电源厂商：</td>
                        <td>
                            <select name="powerSupplierId" class="easyui-combobox" required
                                    style="width: 182px; height: 30px;" editable="false">
                            <#list powerSupplierList as e>
                                <option value="${e.id}">${(e.supplierName)!''}</option>
                            </#list>
                            </select>
                        </td>
                        <td align="right">柜子厂商：</td>
                        <td>
                            <select name="cabinetSupplierId" class="easyui-combobox" required
                                    style="width: 182px; height: 30px;" editable="false">
                            <#list cabinetSupplierList as e>
                                <option value="${e.id}">${(e.supplierName)!''}</option>
                            </#list>
                            </select>
                        </td>
                    </tr>
                    <tr>
                    <#if Session['SESSION_KEY_USER'].type == Session['USER_TYPE_PLATFORM'].value>
                        <td align="right">运营商：</td>
                        <td>
                            <input name="agentId" class="easyui-combotree" editable="false" id="agent_id_${pid}"
                                   style="width: 184px; height: 28px;" required="required"
                                   data-options="url:'${contextPath}/security/basic/agent/tree.htm',method:'get',required:true,onSelect: function(rec){
                               var url = '${contextPath}/security/hdw/agency/tree.htm?agentId='+rec.id;
                               $('#agency_id_${pid}').combotree('reload', url);},
                               onChange:function(){
                                $('#agency_id_${pid}').combotree('clear');
                                $('#cabinet_strategy_id_${pid}').combotree('clear');
                                $('#divite_plan_id_${pid}').combotree('clear');}
                                "/>
                        </td>
                    <#else>
                        <input type="hidden" name="agentId" id="agent_id_${pid}"
                               value="${Session['SESSION_KEY_USER'].agentId}">
                    </#if>
                    <#if Session['SESSION_KEY_USER'].type == Session['USER_TYPE_AGENT'].value||Session['SESSION_KEY_USER'].type == Session['USER_TYPE_PLATFORM'].value>
                        <td align="right">代理商：</td>
                        <td>
                            <input name="agencyId" class="easyui-combotree" editable="false" required="required"
                                   style="width: 184px; height: 28px;" id="agency_id_${pid}"
                                   data-options="<#if Session['SESSION_KEY_USER'].type == Session['USER_TYPE_AGENT'].value>url:'${contextPath}/security/hdw/agency/tree.htm?agentId=${Session['SESSION_KEY_USER'].agentId}',</#if>method:'get',required:true,
                                       onSelect: function(rec){
                                       var url = '${contextPath}/security/hdw/cabinet_strategy/tree.htm?agencyId='+rec.id;
                                       var url2 = '${contextPath}/security/hdw/exchange_amount_money_divide/tree.htm?agencyId='+rec.id;
                                       $('#cabinet_strategy_id_${pid}').combotree('reload', url);
                                       $('#divite_plan_id_${pid}').combotree('reload', url2);},
                                       onChange:function(){
                                        $('#cabinet_strategy_id_${pid}').combotree('clear');
                                        $('#divite_plan_id_${pid}').combotree('clear');}"/>
                        </td>
                    <#else>
                        <!-- 修改-->
                        <input type="hidden" name="agencyId" id="agency_id_${pid}"
                               value="${Session['SESSION_KEY_USER'].agencyId}">
                    </#if>
                    </tr>
                    <tr>
                        <td align="right">策略：</td>
                        <td>
                            <input name="strategyId" class="easyui-combotree" editable="false"
                                   style="width: 184px; height: 28px;" required="required"
                                   id="cabinet_strategy_id_${pid}"
                                   data-options="<#if Session['SESSION_KEY_USER'].type == Session['USER_TYPE_AGENCY'].value>url:'${contextPath}/security/hdw/cabinet_strategy/tree.htm?agentId=${Session['SESSION_KEY_USER'].agentId}&agencyId=${Session['SESSION_KEY_USER'].agencyId}',method:'get'</#if>"/>
                        </td>
                        <td align="right">金额分配：</td>
                        <td>
                            <input name="dividePlanId" class="easyui-combotree" editable="false"
                                   style="width: 184px; height: 28px;" required="required"
                                   id="divite_plan_id_${pid}"
                                   data-options="<#if Session['SESSION_KEY_USER'].type == Session['USER_TYPE_AGENCY'].value>url:'${contextPath}/security/hdw/exchange_amount_money_divide/tree.htm?agentId=${Session['SESSION_KEY_USER'].agentId}&agencyId=${Session['SESSION_KEY_USER'].agencyId}',method:'get'</#if>"/>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">充电温度区间：</td>
                        <td><input type='number' min="0" max="100" name="rpt" class="text easyui-validatebox" value="45"
                                   style="width: 60px" required/>
                            -<input type='number' min="0" max="100" name="pt" class="text easyui-validatebox" value="65"
                                    style="width: 60px" required/>
                        </td>
                        <td align="right">风扇温度区间：</td>
                        <td><input type='number' min="0" max="100" name="fot" class="text easyui-validatebox" value="40"
                                   value="" style="width: 60px" required/>
                            -<input type='number' min="0" max="100" name="fst" class="text easyui-validatebox"
                                    value="50" style="width: 60px" required/>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">开放时间：</td>
                        <td><input type="text" class="text easyui-validatebox" maxlength="40" name="openTime"
                                   value=""/></td>
                        <input type="hidden" name="priceSettingId">
                        <td align="right">套餐：</td>
                        <td>
                            <input type="text" required="true" readonly="readonly" class="text easyui-validatebox"
                                   value="" name="priceSettingName" style="width: 172px; height: 28px;"/>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<div class="popup_btn">
    <button class="btn btn_red ok">确定</button>
    <button class="btn btn_border close">关闭</button>
</div>

<script>
    (function () {
        var win = $('#${pid}'), jform = win.find('form');
        var form = jform[0];
        win.find('button.ok').click(function () {
            jform.form('submit', {
                url: '${contextPath}/security/hdw/cabinet/create.htm',
                success: function (text) {
                    var json = $.evalJSON(text);
                <@app.json_jump/>
                    if (json.success) {
                        $.messager.alert('提示信息', '操作成功', 'info');
                        win.window('close');
                    } else {
                        $.messager.alert('提示信息', json.message, 'info');
                    }
                }
            });
        });
        win.find('button.close').click(function () {
            win.window('close');
        });

        win.find('input[name=priceSettingId],input[name=priceSettingName]').click(function () {
            selectPriceSetting();
        });

        function selectPriceSetting() {
            var agentId=0;
        <#if Session['SESSION_KEY_USER'].type == Session['USER_TYPE_PLATFORM'].value>
             agentId = $('#agent_id_${pid}').combotree('getValue');
        <#else>
                 agentId = $('#agent_id_${pid}').val();
        </#if>
            if (!agentId) {
                $.messager.alert('提示信息', '请先选择运营商', 'info');
                return false;
            }
            App.dialog.show({
                css: 'width:826px;height:522px;overflow:visible;',
                title: '选择套餐',
                href: "${contextPath}/security/hdw/exchange_price_setting/select_price_setting.htm?agentId=" + agentId,
                windowData: {
                    ok: function (config) {
                        win.find('input[name=priceSettingId]').val(config.exchargerPriceSetting.id);
                        win.find('input[name=priceSettingName]').val(config.exchargerPriceSetting.settingName);
                    }
                },
                event: {
                    onClose: function () {
                    }
                }
            });
        }
    })();
</script>
